package org.adorsys.aderp.aderplogin.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;

import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.entity.RooJpaEntity;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaEntity
public class AderpClientDetail implements Serializable {

	private static final long serialVersionUID = 1L;

	@NotNull
    @Column(name = "clientNrBk", unique = true)
    private String clientNr;

    @NotNull
    @Column(name = "clientIdImtble", unique = true)
    private String clientId;

    @NotNull
    @Column(name = "clientSecretImtble")
    private String clientSecret;

    @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
    private Set<ClientRole> clientRoles = new HashSet<ClientRole>();

    @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
    private Set<ClientScope> clientScopes = new HashSet<ClientScope>();

    @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
    private Set<ClientResource> clientResources = new HashSet<ClientResource>();

    private String authorizedGrantTypes;

    private String registeredRedirectUri;
    
    private String rolePrefixes;

	public String getRolePrefixes() {
		return rolePrefixes;
	}

	public void setRolePrefixes(String rolePrefixes) {
		this.rolePrefixes = rolePrefixes;
	}

	public AderpClientDetail cloneObject()  {
		AderpClientDetail clone = new AderpClientDetail();
		clone.clientNr = clientNr;
		clone.clientId = clientId;
		clone.clientSecret = clientSecret;
		clone.authorizedGrantTypes = authorizedGrantTypes;
	    clone.registeredRedirectUri = registeredRedirectUri;
	    clone.rolePrefixes = rolePrefixes;
	    clone.clientResources = new HashSet<ClientResource>(clientResources);
	    clone.clientRoles = new HashSet<ClientRole>(clientRoles);
	    clone.clientScopes = new HashSet<ClientScope>(clientScopes);
		return clone;
	}
    
	
}
